Skip to content

Super-fork: cherry-pick features from 8 community forks - #253

Open
FarelRA wants to merge 5 commits into
jwadow:mainfrom
FarelRA:main
Open

Super-fork: cherry-pick features from 8 community forks#253
FarelRA wants to merge 5 commits into
jwadow:mainfrom
FarelRA:main

Conversation

@FarelRA

@FarelRA FarelRA commented Jul 19, 2026

Copy link
Copy Markdown

Summary

Super-fork that cherry-picks all unique features from 8 community forks (FarelRA, hnewcity, BcGee, Yorick-Ryu, severity1, gaoshan5211, Echoxiawan, leikaiwei) into a single clean codebase.

New features cherry-picked:

  • Tool name aliasing (extensions/tool_name_alias.py) — configurable tool name remapping
  • Profile ARN management (kiro/profile_arn.py) — centralized profile ARN with fallback
  • Models/routes/responses modules — cleaner separation of concerns
  • PDF extraction — pypdf-based document content extraction
  • SOCKS5 proxy support — via httpx[socks]

Bug fixes applied:

  • Full suite of 79 test errors fixed (session fixture now patches OS env vars)
  • ResourceWarning from unclosed SQLite connections in auth.py
  • StarletteDeprecationWarning suppressed in test conftest
  • RuntimeWarnings from unawaited async generators eliminated

Quality:

  • 1673 unit tests passing with 0 warnings
  • profile_arn_for_payload() centralized and wired across all 4 route files
  • PROXY_AUTH_DISABLED wired into both OpenAI and Anthropic auth
  • Live model catalog refresh on /v1/models
  • Content-Type fixed to application/json

FarelRA added 3 commits July 18, 2026 16:59
Cherry-picks all unique features from FarelRA, hnewcity, BcGee,
Yorick-Ryu, severity1, gaoshan5211, Echoxiawan, and leikaiwei forks.

Changes:
- Account system: Circuit Breaker, sticky behavior, lazy init, multi-account
- API region: auto-detection from profile ARN with env-var override
- Auth: support for social login (Google/GitHub) and Enterprise Kiro IDE
- Config: ACCOUNTS_CONFIG_FILE, MODEL_CACHE_TTL, PROXY_AUTH_DISABLED
- Converters: responses API format, document/PDF extraction, thinking blocks
- Debug logger: per-request archival, mode=all/mode=errors
- Extensions: tool name aliasing system
- HTTP: SOCKS5 proxy support, connection timeout detection
- Models: dynamic resolution, fallback models, hidden model support
- Parsers: inverted model names support, Cursor flat format
- Profile ARN: centralized profile_arn_for_payload() helper
- Routes: /v1/responses endpoint, /v1/usage endpoint, PROXY_AUTH_DISABLED
- Streaming: first-token timeout with retry for both APIs
- Token counting with tiktoken
- Truncation recovery system
- Network error classification with user-friendly messages
- PDF text extraction from document content blocks (both APIs)
- Live model catalog refresh on /v1/models endpoint
- Content-Type: migrated from x-amz-json-1.0 to application/json

Fixes:
- Session fixture: set OS env vars so config module reloads preserve
  temp credential paths (fixes 79 test errors in full-suite runs)
- All 1673 unit tests passing
…ning

- Fix 3 async generator warnings by using real timeouts instead of
  patching asyncio.wait_for (avoids unawaited coroutines)
- Add gen.aclose() cleanup in all 3 affected tests
- Suppress StarletteDeprecationWarning in conftest.py (httpx2 not yet
  available in starlette 1.3.1)
- Remove stale pytest.ini filterwarnings that were not matching
- 1673 tests pass with 0 warnings
@cla-bot

cla-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

…talog

Replace the hardcoded native-reasoning tables with per-model schemas fetched
from the Kiro control plane. ListAvailableModels on management.{region}.kiro.dev
advertises each model's additionalModelRequestFieldsSchema, which declares whether
the model supports native adaptive thinking and exactly which effort levels it
accepts. Binding to that ground truth fixes two problems in the static approach:
requesting native effort on models that don't support it, and sending effort
values (e.g. "xhigh") outside the server's strict enum.

- kiro/native_reasoning.py: new registry that parses each model's advertised
  additionalModelRequestFieldsSchema into an effort descriptor (schema type,
  valid effort enum, default) and clamps a requested effort onto the advertised
  set (xhigh -> max when the model only offers low/medium/high/max).
- account_manager: fetch the catalog from the control plane (management host,
  ListAvailableModels JSON-1.0 RPC) for all accounts, including runtime-endpoint
  ones, and register the advertised schemas on init and TTL refresh. Falls back
  to static models on failure. Removes the runtime-endpoint fetch short-circuit.
- converters_core.build_native_effort_fields: consult the catalog registry first
  (static config table only as fallback) and clamp effort to the advertised enum.
- auth: add management_host; config: point KIRO_MANAGEMENT_HOST_TEMPLATE at
  management.{region}.kiro.dev; http_client: allow per-request extra_headers so
  the catalog RPC can set its x-amz-target.

Verified live against a Kiro subscription: management host returns HTTP 200 for
origin=AI_EDITOR, and only claude-opus-4.6/sonnet-4.6 advertise effort
(low/medium/high/max), which the registry picks up automatically.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gszhX9bogSALZ4S9AR1Vq
@mark-os

mark-os commented Jul 19, 2026

Copy link
Copy Markdown

Nice work consolidating the forks. I built a follow-up on top of this branch that makes the native reasoning path catalog-driven instead of relying on the hardcoded NATIVE_EFFORT_SCHEMA_BY_MODEL / VALID_EFFORT_LEVELS tables: FarelRA#1.

The Kiro control plane (management.{region}.kiro.dev) advertises each model's additionalModelRequestFieldsSchema via ListAvailableModels, which declares whether a model supports native adaptive thinking and exactly which effort levels it accepts. Deriving the behavior from that schema fixes two things in the static approach:

  • Out-of-enum effort: xhigh isn't in the advertised enum (low/medium/high/max), and additionalProperties:false means the server rejects it — so Claude Code sending xhigh would 400. It now clamps to the nearest advertised level (xhigh → max).
  • Unsupported models: native effort was offered for models the backend doesn't advertise a schema for (varies by subscription).

Verified live: the management host returns HTTP 200 for origin=AI_EDITOR, and only claude-opus-4.6/claude-sonnet-4.6 advertised effort on my account (low/medium/high/max) — picked up automatically, no code change needed as a subscription gains models. Opened against your fork since the native-reasoning base lives in this branch, not upstream yet. Full suite 1709 passing.

feat(reasoning): drive native reasoning effort from the live model catalog
@cla-bot

cla-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

@FarelRA

FarelRA commented Jul 19, 2026

Copy link
Copy Markdown
Author

I have read the CLA and I accept its terms

@FarelRA

FarelRA commented Jul 19, 2026

Copy link
Copy Markdown
Author

Merged FarelRA#1 (catalog-driven native reasoning by @mark-os) into this branch. The super-fork now includes all changes from that PR as well. Full suite passing with 1691 tests.

@mark-os

mark-os commented Jul 19, 2026

Copy link
Copy Markdown

I have read the CLA and I accept its terms

@FarelRA

FarelRA commented Jul 19, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot

cla-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

@cla-bot

cla-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants